package com.budwk.app.sqfwV2.enums.publicSecurity;

import com.budwk.app.sqfwV2.enums.DayingRoadFileServiceEnum;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * 大营路文件对应枚举
 */
@Getter
public enum PublicSecurityFileEnum {
    PUBLIC_SECURITY_STANDING_BOOK(1, "public_security_standing_book", "【社会治安重点风险场所】台账", "sqfwV2/publicSecurity/publicSecurityKeyRiskAreasStandingBook.xlsx",
            "sqfwV2/publicSecurity/template/publicSecurityKeyRiskAreasStandingBook.xlsx", "/preview/publicSecurity/ty-excel.png", "台账|社会治安", "xlsx", "TY", "f106190fd404476c9af6b053a55736d2"),

    PUBLIC_SECURITY_STANDING_PDF(2, "public_security_standing_pdf", "【社会治安重点风险场所】合集", "sqfwV2/publicSecurity/publicSecurityCheck.docx",
            "sqfwV2/publicSecurity/template/publicSecurityCheck.docx", "/preview/publicSecurity/ty-pdf.png", "社会治安", "docx", "TY", "01d8e83a86104c6b886ad0ffa0a25be1"),

    PUBLIC_SECURITY_STANDING_BOOK_GSHQ(1, "public_security_standing_book_gshq", "【社会治安重点风险场所】台账", "sqfwV2/publicSecurity/publicSecurityKeyRiskAreasStandingBookGSHQ.xlsx",
            "sqfwV2/publicSecurity/template/publicSecurityKeyRiskAreasStandingBookGSHQ.xlsx", "/preview/publicSecurity/gs-excel.png", "全部数据|台账|社会治安", "xlsx", "GS", "0181c359cdd44152883deb54d7ea216e"),

    PUBLIC_SECURITY_STANDING_PDF_GSHQ(2, "public_security_standing_pdf_gshq", "【社会治安重点风险场所】合集", "sqfwV2/publicSecurity/publicSecurityCheckGSHQ.docx",
            "sqfwV2/publicSecurity/template/publicSecurityCheckGSHQ.docx", "/preview/publicSecurity/gs-pdf.png", "全部数据|社会治安", "docx", "GS", "041e302239f74b198a63070700124a3d");

    private final Integer number;

    private final String code;

    private final String name;

    private final String templatePath;

    private final String emptyTemplatePath;

    private final String previewImage;

    private final String label;

    private final String suffix;

    private final String fileMark;//文件标识，TY(通用)，GS（观山)

    private final String templateId;//模板id


    PublicSecurityFileEnum(Integer number, String code, String name, String templatePath, String emptyTemplatePath, String previewImage, String label, String suffix, String fileMark, String templateId) {
        this.number = number;
        this.code = code;
        this.name = name;
        this.templatePath = templatePath;
        this.emptyTemplatePath = emptyTemplatePath;
        this.previewImage = previewImage;
        this.suffix = suffix;
        this.label = label;
        this.fileMark = fileMark;
        this.templateId = templateId;

    }

    public static PublicSecurityFileEnum getPublicSecurityFileByCode(String code) {
        for (PublicSecurityFileEnum o : PublicSecurityFileEnum.values()) {
            if (o.getCode().equals(code)) {
                return o;
            }
        }
        return null;
    }

    public static PublicSecurityFileEnum getPublicSecurityFileByFileMarkAndSuffix(String fileMark, String suffix) {
        for (PublicSecurityFileEnum o : PublicSecurityFileEnum.values()) {
            if (o.getFileMark().equals(fileMark) && o.getSuffix().equals(suffix)) {
                return o;
            }
        }
        return null;
    }

    public static List<PublicSecurityFileEnum> listByMark(String fileMark) {
        return Arrays.stream(values()).filter(e -> e.getFileMark().equals(fileMark)).collect(Collectors.toList());
    }

    public static PublicSecurityFileEnum getByCode(String fileCode) {
        Optional<PublicSecurityFileEnum> optional = Arrays.stream(values()).filter(e -> e.getCode().equals(fileCode)).findFirst();
        return optional.orElse(null);
    }
}
